#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    int n,k;
    cin>>n>>k;
    if(k==0)k=n;
    string s;
    cin>>s;
    ll ans=0;
    int ca=0,cb=0,cc=0;
    int r=0;
    for(int l=0;l<n;l++){
        while(r<n&&(ca==0||cb==0||cc==0)){
            if(s[r]=='a')ca++;
            else if(s[r]=='b')cb++;
            else if(s[r]=='c')cc++;
            r++;
        }
        if(ca>0&&cb>0&&cc>0){
            int minn=r-1;
            int maxn=min(l+k-1,n-1);
            if(minn<=maxn){
                ans+=(maxn-minn+1);
            }
        }
        if(s[l]=='a')ca--;
        else if(s[l]=='b')cb--;
        else if(s[l]=='c')cc--;
    }
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}
